/**
 * Bestpay.com.cn Inc.
 * Copyright (c) 2011-2020 All Rights Reserved.
 */
package com.suxiaoxiao.springbootlearn.designpattern.templatepattern.hookdemo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * desc
 *
 * @author zhaorongzhang
 * @version CoffeeWithHook.java, v 0.1 2020/1/4 2:31 下午 zhaorongzhang Exp $$
 */
public class TeaWithHook extends CaffeineBeverageWithHook {

    @Override
    protected void brew() {
        System.out.println("Steeping the tea");
    }

    @Override
    protected void addCondiments() {
        System.out.println("Adding lemon");
    }

    /**
     * 钩子函数的用法
     * @return
     */
    @Override
    boolean customerWantCondiments() {
        String answer = getUserInput();

        if (answer.toLowerCase().startsWith("y")) {
            return true;
        } else {
            return false;
        }
    }

    private String getUserInput() {
        System.out.println("Would you like lemon with your tea (y/n) ?");
        return getString();
    }


}